home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / OpenGL 1.0 SDK / Source / Libraries / glut / glut_swidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-18  |  1015 b   |  47 lines  |  [TEXT/CWIE]

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1995. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include "glut.h"
  9. #include "glutint.h"
  10. #include "glutstroke.h"
  11.  
  12. int glutStrokeLength(GLUTstrokeFont font, const unsigned char *string);
  13.  
  14. int glutStrokeWidth(GLUTstrokeFont font, int c)
  15. {
  16.   StrokeFontPtr fontinfo = (StrokeFontPtr) font;
  17.   StrokeCharPtr ch;
  18.  
  19.   if (c < 0 || c >= fontinfo->num_chars)
  20.     return 0;
  21.   ch = &(fontinfo->ch[c]);
  22.   if (ch)
  23.     return ch->right;
  24.   else
  25.     return 0;
  26. }
  27.  
  28. int glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
  29. {
  30.   int c, length;
  31.   StrokeFontPtr fontinfo = (StrokeFontPtr) font;
  32.   StrokeCharPtr ch;
  33.  
  34.   length = 0;
  35.   for (; *string != '\0'; string++) {
  36.     c = *string;
  37.     if (c < 0 || c >= fontinfo->num_chars) {
  38.       ch = &(fontinfo->ch[c]);
  39.       if (ch)
  40.     length += ch->right;
  41.     }
  42.   }
  43.   return length;
  44. }
  45.  
  46. /* ENDCENTRY */
  47.